package com.itheima.edu.info.manager.day15;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class TcpServerShuangXiang {
    public static void main(String[] args) throws IOException {

        ServerSocket ss=new ServerSocket(4396);
        Socket accept = ss.accept();
        InputStream is= accept.getInputStream();
        byte [] b=new byte[3333];
        OutputStream os=new FileOutputStream("C://Users//LOVE//Desktop//a.exe");
        int a;
        while ((a=is.read(b))!=-1)
        os.write(b,0,b.length);


        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        String s= "传输成功";
        bw.write(s);
        //换行
        bw.newLine();
        //刷新
        bw.flush();
        os.close();
        is.close();
        ss.close();
    }
}
